using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Elo.Exemplo.EFCodeFirst.Domain.Entities;

namespace Elo.Exemplo.EFCodeFirst.Domain.Mapping
{
	public class CategoryMap : EntityTypeConfiguration<Category>
	{
		public CategoryMap()
		{
			// Primary Key
			this.HasKey(t => t.CategoryID);

			// Properties
			this.Property(t => t.CategoryName)
				.IsRequired()
				.HasMaxLength(15);
				
			// Table & Column Mappings
			this.ToTable("Categories");
			this.Property(t => t.CategoryID).HasColumnName("CategoryID");
			this.Property(t => t.CategoryName).HasColumnName("CategoryName");
			this.Property(t => t.Description).HasColumnName("Description");
			this.Property(t => t.Picture).HasColumnName("Picture");
		}
	}
}

